import { requestApi } from "@/utils/request";
import type { UserCountResponse, UserTravelResponse } from "@/types/mine";

// 获取用户的点赞，关注，粉丝数量
export const getUserCountAPI = () => {
    return requestApi<UserCountResponse>({
        url: '/my-related',
        method: 'GET'
    })
}

// 查用户发布的游记
export const getUserTravelAPI = (page: number) => {
    return requestApi<UserTravelResponse>({
        url: '/myTravEls',
        method: 'GET',
        data: {
            page: page
        }
    })
}

// 查询用户收藏的游记
export const getUserCollectionAPI = (page: number) => {
    return requestApi<UserTravelResponse>({
        url: '/myCollEction',
        method: 'GET',
        data: {
            page: page
        }
    })
}

// 查询用户点赞的游记
export const getUserLikeAPI = (page: number) => {
    return requestApi<UserTravelResponse>({
        url: '/myLikeArticle',
        method: 'GET',
        data: {
            page: page
        }
    })
}

// 统一的游记列表查询（作品/收藏/喜欢）
export type UserTravelListType = 'works' | 'collection' | 'like'
export const getUserTravelListAPI = (type: UserTravelListType, page: number) => {
    const urlMap: Record<UserTravelListType, string> = {
        works: '/myTravEls',
        collection: '/myCollEction',
        like: '/myLikeArticle'
    }
    return requestApi<UserTravelResponse>({
        url: urlMap[type],
        method: 'GET',
        data: {
            page
        }
    })
}